package com.tanhua.dubbo.server.service;

import com.tanhua.dubbo.server.enums.IdType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @author feihao
 * @version 1.0
 * @date 2021/7/1 23:44
 */


//使用redis的自增长值   创建PublishId;
@Service
public class IdService {

    @Autowired
    private RedisTemplate<String,String> redisTemplate;


    public Long createPid(IdType idType) {
        String idKey = "TANHUA_ID_" + idType.toString();
        System.out.println(redisTemplate.opsForValue().get(idKey));
        Long increment = redisTemplate.opsForValue().increment(idKey);
        System.out.println(increment);
        return increment;
    }
}
